<!DOCTYPE html>
<html style="background-color: #f2e8e7;">
<head>
  <meta charset="utf-8">
  <title>设备故障报警</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
</head>
<body>
  <div class="layui-form" lay-filter="layuiadmin-form-role" id="layuiadmin-form-role" style="margin: 20px">
    <h3><span class="alStation"></span> 于<span class="alTime"></span> <span class="alMsg"></span></h3>
    <div class="record-formtitle">基本信息</div>
    <div class="layui-row form-row">
      <div class="layui-col-md6">
        <div class="layui-form-item">
            <div class="itemTr">站点名称:<span class="alStation"></span></div>
        </div>
        <div class="layui-form-item">
            <div class="itemTr">发生时间:<span class="alTime"></span></div>
        </div>
        <div class="layui-form-item">
          <div class="itemTr">报警来源:<span class="deviceCn"></span></div>
      </div>
      </div>
      <div class="layui-col-md6">
        <div class="layui-form-item">
            <div class="itemTr">报警类型:<span class="alRank"></span></div>
        </div>
        <div class="layui-form-item">
            <div class="itemTr">报警状态:<span class="regainStatu"></span></div>
        </div>
        <div class="layui-form-item">
            <div class="itemTr">关联设备:<span id="maintenanceFlag"></span></div>
        </div>
      </div>
      <!-- <div class="layui-col-md2">
        <img src="../../layuiadmin/images/alarmRank1.jpg" class="alRankImg"/>
      </div> -->
    </div>
    <div>
      <h2>报警内容</h2>
      <h3><span class="alTime"></span> <span class="alStation"></span> <span class="alMsg"></span></h3>
    </div>
    <div class="layui-form" lay-filter="layuiadmin-form-role" id="layuiadmin-form-role" style="padding: 20px 30px 0 0;">
    <button class="layui-btn layuiadmin-btn-admin createOrder">创建维修工单</button>
      <div class="record-formtitle">维修记录</div>
      <table id="maintenanceRecord" lay-filter="maintenanceRecord"></table>   
        </div>
      </div>
    <div class="layui-form-item layui-hide">
      <button class="layui-btn" lay-submit lay-filter="LAY-user-role-submit" id="LAY-user-role-submit">提交</button>
    </div>
  </div>
  <script type="text/html" id="forTaskStatus">
    {{#  if(d.statu == '0'){d.statu = '已恢复'}}
    {{d.statu}}
    {{#  } else if (d.statu == '1'){d.statu = '处理中' }}
    {{d.statu}}
    {{#  } else if (d.statu == '2'){d.statu = '已搁置' }}
    {{d.statu}}
    {{#  } else if (d.statu == '3'){d.statu = '未处理' }}
    {{d.statu}}
    {{#  } else {d.statu = '已处理' }}
    {{d.statu}}
    {{#  } }}
</script>
  <script src="../../layuiadmin/layui/layui.js"></script>  
  <script>
   function initData(data){
      layui.config({
        base: '../../layuiadmin/' //静态资源所在路径
      }).extend({
        index: 'lib/index' //主入口模块
        , my_send: '../myModules/my_send'
      }).use(['index', 'form','laydate','table','my_send'], function () {
        var $ = layui.$
        , form = layui.form
        ,laydate = layui.laydate
        ,table = layui.table
        , my_send = layui.my_send
        , http_proxy = layui.http_proxy;
        laydate.render({
          elem: '#maintenanceDate' //指定元素
          ,type: 'datetime'
        });
        if(data.alRank == 1){
          data.alRank = '一级';
          // $('.alRankImg').attr("src","../../layuiadmin/images/alarmRank1.jpg");
        }else if(data.alRank == 2){
          data.alRank = '二级';
          // $('.alRankImg').attr("src","../../layuiadmin/images/alarmRank2.jpg")
        }else if(data.alRank == 3){
          data.alRank ='三级';
          // $('.alRankImg').attr("src","../../layuiadmin/images/alarmRank3.jpg")
        }else{
          data.alRank = '四级';
          // $('.alRankImg').attr("src","../../layuiadmin/images/alarmRank4.jpg")
        }
        if(data.regainStatu == 1){
          data.regainStatu = '紧急'
        }else if(data.regainStatu == 2){
          data.regainStatu = '高'
        }else if(data.regainStatu == 3){
          data.regainStatu ='中'
        }else{
          data.regainStatu = '低'
        }
        $('.alStation').html(data.alStation);
        $('.alTime').html(data.alTime);
        $('.alMsg').html(data.alMsg);
        $('.deviceCn').html(data.deviceCn);
        $('.alRank').html(data.alRank);
        $('.regainStatu').html(data.regainStatu);
        $('#devType').html(data.eventType);
        $('#devTypeValue').html(data.eventType);
        $('#specialtyValue').html(data.doMain);
        $('#maintenanceFlag').html(data.maintainWay === '1' ? '计划维修':'检修');
        $('#maintenanceDate').val(data.maintenanceDate)
        $('#maintenancePersonName').val(data.maintenancePersonName);
         //维修记录
         table.render({
          elem: '#maintenanceRecord'
          , url: http_proxy('/alertManager/queryMtRecord') //数据接口
          ,where:{
            eventType:data.deviceCn,
            stations:data.alStation
          }
          , page: true //开启分页
          , method: 'post'
          , contentType : "application/json"
          ,parseData:function(res){
            return{
              "code":0
              ,"count":res.total
              ,"data":res.rows
              ,'msg':''
            }
          }
          ,cols: [[
            {field: 'taskNum', title: '工单号',align: 'center'}
            ,{field: 'maintainDate', title: '维修日期',align: 'center'}
            ,{field: 'maintainWay', title: '维修方式',align: 'center'}
            ,{field: 'maintainPerson', title: '维修人'}
            ,{field: 'maintainContent', title: '维修内容',align: 'center'}
            ,{field: 'taskStatus', title: '工单状态',templet:'#forTaskStatus',align: 'center'}
           
          ]]
        });
        $('.createOrder').on('click',function() {
          layer.open({
            type: 2
            ,title: '添加维护计划'
            ,content: '../equipment/plan-addForm.html'
            ,area: ['90%', '90%']
            ,btn: ['确定', '取消']
            ,yes: function(index, layero){
              //点击确认触发 iframe 内容中的按钮提交
              var submit = layero.find('iframe').contents().find("#layuiadmin-app-form-submit");
              submit.click();
            }
          }); 
        });
      })
    }
  </script>
</body>
</html>